package com.spring.bean.container;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.ClassPathResource;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import java.lang.reflect.Constructor;

import static org.junit.jupiter.api.Assertions.assertEquals;

/**
 * @ClassName: BeanFactoryTest
 * @Author: suncx
 * @CreateDate: 2020-03-17 11:4bean6
 * @Description:
 */
@ContextConfiguration(locations = { "classpath:log4j2.xml" })
public class BeanFactoryTest {
    @Test
    public void beanFactoryTest() {
        BeanFactory bf = new XmlBeanFactory(new ClassPathResource("/bean/BeanFactoryTest.xml"));
        MyBeanTest myBeanTest = (MyBeanTest)bf.getBean("myBeanTest");
        MyBeanTest myBeanTest2 = (MyBeanTest)bf.getBean("myBeanTest");
        assertEquals ("testStr", myBeanTest.getTestStr());
        System.out.println(myBeanTest == myBeanTest2);
        System.out.println(myBeanTest.testSpringAu(null));
    }


    @Test
    public void cycleset() {
        try {
            Constructor constructorToUse = MyBeanTest.class.getConstructor();
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        }
    }
}
